package com.example.administrator.shzs.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.administrator.shzs.R;
import com.example.administrator.shzs.entity.GiftOrdeData.GiftOrdeListData;
import java.util.List;

/**
 * Created by Administrator on 2016/11/4.
 */

public class GiftOrdeAdapter extends RecyclerView.Adapter<GiftOrdeAdapter.MyViewHolder>{

    private Context context;
    private List<GiftOrdeListData> listDatas;

    public GiftOrdeAdapter(Context context, List<GiftOrdeListData> listDatas) {
        this.context = context;
        this.listDatas = listDatas;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view=View.inflate(context,R.layout.gift_orde_item,null);

        MyViewHolder holder=new MyViewHolder(view);

        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {

        holder.tvGiftName.setText(listDatas.get(position).getGiftName());
        holder.tvPayIntegra.setText(listDatas.get(position).getPayIntegral());
        holder.tvExchangeDate.setText(listDatas.get(position).getCdate());
    }

    @Override
    public int getItemCount() {
        return listDatas==null ? 0 :listDatas.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder{

        private TextView tvGiftName;//礼品名
        private TextView tvPayIntegra;//使用积分
        private TextView tvExchangeDate;//兑换日期

        public MyViewHolder(View itemView) {
            super(itemView);

            tvGiftName= (TextView) itemView.findViewById(R.id.tv_gife_name);
            tvPayIntegra= (TextView) itemView.findViewById(R.id.tv_pay_integral);
            tvExchangeDate= (TextView) itemView.findViewById(R.id.tv_exchange_date);

        }
    }
}
